##################################################################
DEBUG = y
##################################################################
ifeq ($(DEBUG),y)
GDBOPTS= -g -DYYDEBUG
endif
INCLUDES = -I./ -I Contexts -I Lists -I Posets -I Subsets  -I Algos
WARNINGS = -Wall -pedantic
OTHEROPTS=-lfl
# compiler
CC = gcc                       
CFLAGS = $(INCLUDES) $(GDBOPTS) $(WARNINGS)
CPPFLAGS = $(INCLUDES)
# lex
LEX=flex
CTXPREFIX=ctxctx
LEXOPTS=-P$(CTXPREFIX)
# yacc
YACC=bison
YACCOPTS=-d -p $(CTXPREFIX)
##################################################################
TOKENSSRC = Contexts/contexts_tokens.l
GRAMMARSRC = Contexts/contexts_grammar.y
SRCS = $(shell ls -f */*.c) contexts_grammar.c tokens.c
OUTPUTFILE = ctx2lat
##################################################################
INSTALLATIONDIR=../bin/

all: ctx2lat ctxreduce install

ctx2lat: tokens grammar dep ctx2lat.o $(SRCS:.c=.o)
	gcc $(CFLAGS) $(SRCS) ctx2lat.c -o ctx2lat

ctxreduce:  tokens grammar dep ctxreduce.o
	gcc $(CFLAGS) $(SRCS) ctxreduce.c -o ctxreduce

ifeq (.depend,$(wildcard .depend))
include .depend
endif

dep:
	gcc $(CPPFLAGS) -MM $(SRCS) > .depend

grammar: $(GRAMMARSRC)
	$(YACC) -o contexts_grammar.c $(YACCOPTS) $(GRAMMARSRC)

tokens: $(GRAMMARSRC) $(TOKENSSRC) 
	$(LEX) -otokens.c $(LEXOPTS) $(TOKENSSRC)

install:
	cp ctx2lat ctxreduce $(INSTALLATIONDIR)

clean:
	rm -f *.o *./*.o *~

doc:
	doxygen Doxyfile


